#ifndef _H_STM32_HAL_UART_H_
#define _H_STM32_HAL_UART_H_
#include "main.h"

typedef enum
{
    h_stm32_hal_uart_ok = 0,
    h_stm32_hal_uart_enable,
    h_stm32_hal_uart_disable,
    h_stm32_hal_uart_malloc_failed,
}h_stm32_hal_uart_state;

typedef struct
{
    UART_HandleTypeDef *uartHandle;
    h_stm32_hal_uart_state rxDMAEnable;
    DMA_HandleTypeDef *uartRxDMA;
    unsigned char *rxBuffer;
    unsigned short rxLength;
    void (* receiveCallback)(unsigned char *data, unsigned short len); 
}h_stm32_hal_uart_t;

extern void h_stm32_hal_uart_printf_init(UART_HandleTypeDef *handle);
extern h_stm32_hal_uart_t h_stm32_hal_uart_init(UART_HandleTypeDef *handle, \
                            h_stm32_hal_uart_state rxEnable, DMA_HandleTypeDef *dma, \
                            unsigned short rxlen, void *callback);
extern h_stm32_hal_uart_state h_stm32_hal_uart_startReceive(h_stm32_hal_uart_t *uart_t);
extern h_stm32_hal_uart_state h_stm32_hal_uart_handleReceive(h_stm32_hal_uart_t *uart_t);

extern void debug_hex(unsigned char *data, unsigned short len);
#endif
